import info.gridworld.actor.Actor;
import info.gridworld.actor.Critter;
import info.gridworld.grid.Grid;
import info.gridworld.grid.Location;

import java.awt.Color;
import java.util.ArrayList;

public class QuickCrab extends CrabCritter {
    public ArrayList<Location> getMoveLocations() {
        ArrayList<Location> locs = new ArrayList<Location>();
        int[] dirs =
                {Location.LEFT, Location.RIGHT};
        Grid grid = this.getGrid();
        for (int dir : dirs) {
            Location tmp = this.getLocation().getAdjacentLocation(this.getDirection() + dir);
            Location loc = tmp.getAdjacentLocation(this.getDirection() + dir);
            if (grid.isValid(tmp) && grid.isValid(loc) && grid.get(loc) == null && grid.get(tmp) == null)
                locs.add(loc);
        }

        if (locs.isEmpty()) {
            for (Location loc : getLocationsInDirections(dirs))
                if (getGrid().get(loc) == null)
                    locs.add(loc);
        }
        return locs;
    }
}
